function i1i2i3 = rgb2i1i2i3(rgb)
% RGB2I1I2I3 converts image RGB from RGB to I1I2I3 colorspace

% Project:  Similarity function evaluation @CVL/TUWIEN
% Author:   Thomas Rittler (0125728)
% Date:     01/2011

tm = [1/3 1/3 1/3; .5 0 -.5; -.25 .5 -.25]; % transformation matrix
[w h c] = size(rgb);
rgb = reshape(im2double(rgb), [], c)';
i1i2i3 = (reshape((tm*rgb)', w, h, c)+1)/2; % normalize to [0 1]